/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.openbravo.data.gui;

import e.odbo.data.bean.IKeyed;

/**
 *
 * @author Administrator
 */
public class ComboBoxValEntry implements IKeyed{
    public  static String TYPE_null="";
    public static String TYPE_all="all";

    public static String LOCAL_TYPE_null="list.TYPE_null";
    public static String LOCAL_TYPE_all="list.TYPE_null";

    protected Object m_sKey;
    protected String m_sValue;

    public ComboBoxValEntry(Object m_sKey, String m_sValue) {
        this.m_sKey = m_sKey;
        this.m_sValue = m_sValue;
    }

    public ComboBoxValEntry(String m_sKey, String m_sValue) {
        this.m_sKey = m_sKey;
        this.m_sValue = m_sValue;
    }

    public ComboBoxValEntry(int m_sKey, String m_sValue) {
        this.m_sKey = m_sKey;
        this.m_sValue = m_sValue;
    }

    @Override
    public Object getKey() {
       return m_sKey;
    }

    public Object getM_sKey() {
        return m_sKey;
    }

    public void setM_sKey(Object m_sKey) {
        this.m_sKey = m_sKey;
    }

    public String getM_sValue() {
        return m_sValue;
    }

    public void setM_sValue(String m_sValue) {
        this.m_sValue = m_sValue;
    }

    @Override
    public String toString() {
        return  m_sValue;
    }

    @Override
    public boolean equals(Object obj) {
        if(obj==null)
            return false;
        if(obj instanceof IKeyed)
            return ((IKeyed)obj).getKey().equals(getKey());
        return getKey().equals(obj);
    }


    public static ComboBoxValEntry buildEntryByKey(int m_sKey){
        return new ComboBoxValEntry(m_sKey,null);
    }

    public static ComboBoxValEntry buildEntryByKey(String m_sKey){
        if(m_sKey==null)
            return buildEntry_null();
        return new ComboBoxValEntry(m_sKey,null);
    }

    public static ComboBoxValEntry buildEntryByKey(Object m_sKey){
        return new ComboBoxValEntry(m_sKey,null);
    }

    public static ComboBoxValEntry buildEntry_null(){
        return new ComboBoxValEntry(ComboBoxValEntry.TYPE_null,ComboBoxValEntry.LOCAL_TYPE_null);
    }

    public static ComboBoxValEntry buildEntry_all(){
        return new ComboBoxValEntry(ComboBoxValEntry.TYPE_all,ComboBoxValEntry.LOCAL_TYPE_all);
    }
}
